import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.NoSuchAlgorithmException;

import javax.swing.JOptionPane;


public class EircomEncryApp {

	public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
		String num;
		String s;
		
		num = JOptionPane.showInputDialog("Insert eircom wireless number:\n");
		
		/********************************
		Getting MAC Address from serial
		********************************/
		
		//Convert SSID from octal to decimal
		int dec = Integer.parseInt(num, 8);
		//Convert from decimal to hex
		String hex = Integer.toHexString(dec);
		
		//XOR
		hex = Integer.toHexString(dec ^ 4044);
		
		//Add the 0x01000000 to the start
		hex = "01" + hex;

		int serial = Integer.parseInt(hex,16);
		
		//Convert serial numbers to word numbers, and append text
		s = EircomEncryMethods.NumsToWords(Integer.toString(serial)) + "Although your world wonders me, ";
		//Hash result
		s = AeSimpleSHA1.SHA1(s);
		//Take first 26 numbers
		s = s.substring(0, 26);
		//Print out encryption key
		/*String value = (String)*/JOptionPane.showInputDialog(null,"Encryption Key:", "Encryption Key", JOptionPane.PLAIN_MESSAGE,
			null,null,s);	
		//JOptionPane.showMessageDialog(null,value,"Encryption Key",JOptionPane.INFORMATION_MESSAGE);
		
	}
}
